package com.fjrz.bbxwj.main.host.side

import android.app.Activity
import android.content.Intent
import com.blankj.utilcode.util.FragmentUtils
import com.fjrz.bbxwj.R
import com.fjrz.bbxwj.app.RZApplication
import com.fjrz.bbxwj.entity.User
import com.fjrz.bbxwj.main.mine.UserInfoFragment
import com.module.lemlin.base.BaseAbstractActivity
import kotlinx.android.synthetic.main.activity_info_user.*

class MainUserInfoActivity : BaseAbstractActivity() {

    companion object {

        private const val EXTRA_NAME_USER_INFO = "EXTRA_NAME_USER_INFO"

        fun open(activity: Activity, user: User) {
            val intent = Intent(activity, MainUserInfoActivity::class.java)
            intent.putExtra(EXTRA_NAME_USER_INFO, user)
            activity.startActivity(intent)
        }

    }

    override val layoutResId: Int
        get() = R.layout.activity_info_user

    override fun stateBar(): StatusBar {
        return StatusBar(view = flUserInfoBar)
    }

    override fun initView() {

        (intent?.getSerializableExtra(EXTRA_NAME_USER_INFO) as? User)?.let {
            FragmentUtils.add(
                supportFragmentManager,
                UserInfoFragment.newInstance(it),
                R.id.flUserInfoBody
            )
        }

        ivUserInfoBack.setOnClickListener { finish() }
    }
}